package org.hackystat.iw.projectoverviewer.page.defaultmetrics;

import org.apache.wicket.PageParameters;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.hackystat.iw.projectoverviewer.ProjectOverviewerApplication;
import org.hackystat.iw.projectoverviewer.page.treemap.TreeMapPage;
import org.hackystat.iw.projectoverviewer.test.ProjectOverviewerTestHelper;
import org.junit.Test;

/**
 * Tests the set metrics page.
 * 
 * @author Jianfei Liao
 * @author Nathan Britton
 */
public class TestSetMetricsPage extends ProjectOverviewerTestHelper {
  
  /**
   * Tests the metrics page.
   */
  @Test
  public void testMetricsSetup() { // NOPMD
    WicketTester tester = new WicketTester(new ProjectOverviewerApplication(getTestProperties()));
    PageParameters param = new PageParameters();
    param.put("projectName", "TestProject");
    param.put("strategy", "squarified");
    param.put("colorProvider", "RedGreen Linear");
    param.put("size", "MethodCounts");
    param.put("color", "Coverage");
    
    tester.startPage(SetMetricsPage.class, param);
    
    tester.assertRenderedPage(SetMetricsPage.class);
    
    // submit the form
    FormTester setMetricsForm = tester.newFormTester("metrics-form");
    setMetricsForm.submit("metrics-form");
    
    // should go the treemap page (the sensor data collection will fail)
    tester.assertRenderedPage(TreeMapPage.class);
  }
}
